// packageB/pages/mybaojia/index.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tapIndex: 0,
    modalType: false,
    cid: '', //品类id
    classname: '请选择报价品类',
    classid: '',
    bjlist: [],
    checkAllFlag: false, //全选判断标识
    CheckedAllArr: [], //全选数组
    dataList: [],
    ProvinceAndCity: [],
    ProvinceAndCityIndex: [0, 0],
    city: '',
    cityid: 0,
    provinceid: 0,
    province: '请选择地区',
    pickend: false,
    UName: wx.getStorageSync('FjLoginLog').UName,
    Mobile: wx.getStorageSync('FjLoginLog').Mobile,
    YZMobile: wx.getStorageSync('FjLoginLog').YZMobile,
    LoginUID: wx.getStorageSync('FjLoginLog').UID,
    batchUpdateShow: false, //批量更新弹簧状态
    radio: '1', //调价方式
    batchPrice: '', //调整幅度
    unit: '',
    isupdate: true,
    upLoadImgFile: [], //上传图片和文件
    upLoadImg:[],//上传图片
    upLoadFile:[],//上传附件
    uploadCount:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (JSON.stringify(options) === '{}') {
      this.queryisCJ()
    }
    this.setData({
      Linkman: options.cjname,
      Mobile: options.cjphone,
      ComName: options.cjcomp
    })
    this.queryAddress({})
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    //导航条加载动画
    wx.showNavigationBarLoading()
    //loading 提示框
    wx.showLoading({
      title: 'Loading...',
    })
    if (this.data.tapIndex == 0) {
      this.setData({
        modalType: false,
        cid: '',
        classname: '请选择报价品类',
        classid: '',
        bjlist: [],
        checkAllFlag: false, //全选判断标识
        CheckedAllArr: [], //全选数组
        dataList: [],
        ProvinceAndCity: [],
        ProvinceAndCityIndex: [0, 0],
        city: '',
        cityid: 0,
        provinceid: 0,
        province: '',
        pickend: false,
        batchUpdateShow: false, //批量更新弹簧状态
        radio: '1', //调价方式
        batchPrice: '', //调整幅度
        unit: '',
        isupdate: true,
      })
    } else {
      this.setData({
        checkAllFlag: false,
        CheckedAllArr: []
      })
      this.getDataList()
    }
    setTimeout(function () {
      wx.hideLoading();
      wx.hideNavigationBarLoading();
      //停止下拉刷新
      wx.stopPullDownRefresh();
    }, 1200)
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  goFabu(e){
    this.setData({
      tapIndex: 1,
    })
  },
  onClick(event) {
    this.setData({
      tapIndex: event.detail.name,
    })
    if (event.detail.name == 1) {
      this.setData({
        checkAllFlag: false,
        CheckedAllArr: []
      })
      this.getDataList()
    }
  },
  clickBaojiaDetail(e) {
    // console.log(e)
    let that = this
    let classid = this.data.classid
    if (classid) {
      wx.navigateTo({
        url: "/packageB/pages/addBaojia/addBaojia?classid=" + classid + '&unit=' + this.data.unit,
        success: function (res) {
          // 通过 eventChannel 向被打开页面传送数据
          res.eventChannel.emit('acceptDataFromOpenerPage', that.data.bjlist)
        }
      })
    } else {
      wx.showToast({
        title: '请选择品类',
        icon: 'none'
      })
    }
  },
  clickPinMingDetail(e) {
    if (this.data.isupdate == true) {
      wx.navigateTo({
        url: "/packageB/pages/pinlei/pinlei?phone=" + this.data.Mobile,
      })
    } else {
      wx.showToast({
        title: '品类禁止修改',
        icon: 'none'
      })
    }
  },
  //单选
  onChange(event) {
    this.setData({
      CheckedAllArr: event.detail,
      checkAllFlag: event.detail.length == this.data.dataList.length
    });
  },
  //全选
  checkAll(val) {
    let checkedCount = this.data.CheckedAllArr.length
    let filterList = this.data.dataList.filter(item => item.isshowupbtn == 1)
    if (val.detail && filterList.length > 0) {
      //全选
      let all = filterList.map(item => item.id.toString())
      this.setData({
        CheckedAllArr: all,
        checkAllFlag: true
      })
    } else if (val.detail && filterList.length == 0) {
      wx.showToast({
        title: `没有可以批量更新的报价`,
        icon: 'none'
      })
    } else {
      //取消全选
      if (checkedCount === filterList.length) {
        //如果不增加这个条件判断点击某一项时会全部取消
        this.setData({
          CheckedAllArr: [],
          checkAllFlag: false
        })
      }
    }
  },

  // 查询我的报价
  getDataList() {
    wx.showLoading({
      title: '数据加载中',
    })
    this.data.checkAllFlag = false
    this.data.CheckedAllArr = []

    let input = {
      LoginUID: wx.getStorageSync('FjLoginLog').UID
    }
    app.getDaoPost('api/FeijiuApp/Feijiu_BJ_Get_MyFabu', input, r => {
      wx.hideLoading({
        success: (res) => {},
      })
      r.data.forEach(item => {
        item.isshowsavebtn = false
      });
      this.setData({
        dataList: r.data
      })
    })

  },
  // 地区弹框
  clickBaojiaAddress(e) {
    if (this.data.isupdate == false) {
      wx.showToast({
        title: '地区不能修改',
        icon: 'none'
      })
      return
    } else {
      this.setData({
        modalType: !this.data.modalType
      })
      this.queryAddress()
    }
  },
  onClose() {
    this.setData({
      modalType: !this.data.modalType
    })
  },
  // 滑动筛选城市
  bindChangePickerView(e) {
    // console.log(e, '地区选择')
    this.setData({
      ProvinceAndCityIndex: e.detail.value
    })
  },
  bindpickendview(e) {
    // console.log(e, '地区jieshu')
    this.setData({
      pickend: true
    })
  },
  // 点击确定城市
  surePickerview() {
    let ProvinceAndCityIndex = this.data.ProvinceAndCityIndex,
      ProvinceAndCity = this.data.ProvinceAndCity
    // if (this.data.pickend == true) {
    if (ProvinceAndCity[ProvinceAndCityIndex[0]].pcid == 0) { //第一列是不限
      this.setData({
        city: '',
        cityid: 0,
        province: ProvinceAndCity[ProvinceAndCityIndex[0]].name,
        provinceid: ProvinceAndCity[ProvinceAndCityIndex[0]].pcid,
      })
    } else if (ProvinceAndCity[ProvinceAndCityIndex[0]].pcid != 0 && ProvinceAndCity[ProvinceAndCityIndex[0]].list[ProvinceAndCityIndex[1]].pcid == 0) { //第一列有  第二列不限
      this.setData({
        city: '',
        cityid: ProvinceAndCity[ProvinceAndCityIndex[0]].list[ProvinceAndCityIndex[1]].pcid,
        province: ProvinceAndCity[ProvinceAndCityIndex[0]].name,
        provinceid: ProvinceAndCity[ProvinceAndCityIndex[0]].pcid,
      })
    } else if (ProvinceAndCity[ProvinceAndCityIndex[0]].pcid != 0 && ProvinceAndCity[ProvinceAndCityIndex[0]].list[ProvinceAndCityIndex[1]].pcid != 0) { //第一列有  第二列有
      this.setData({
        city: ProvinceAndCity[ProvinceAndCityIndex[0]].list[ProvinceAndCityIndex[1]].name,
        cityid: ProvinceAndCity[ProvinceAndCityIndex[0]].list[ProvinceAndCityIndex[1]].pcid,
        province: ProvinceAndCity[ProvinceAndCityIndex[0]].name,
        provinceid: ProvinceAndCity[ProvinceAndCityIndex[0]].pcid,
      })
    }
    this.setData({
      modalType: !this.data.modalType,
    })
    // }
  },
  // 查询地区
  queryAddress() {
    let that = this
    //存地区
    var ProAndCity = wx.getStorageSync('ProvinceAndCity');
    if (ProAndCity) {
      this.setData({
        ProvinceAndCity: ProAndCity
      })
    } else {
      app.getDaoPost('api/FeijiuApp/Feijiu_BJ_Get_ProvinceAndCity', {}, r => {
        console.log(r, '地区')
        if (r.code == 200) {
          that.setData({
            ProvinceAndCity: r.data
          })
          wx.setStorageSync('ProvinceAndCity', r.data)
        }
      })
      // wx.request({
      //   url: app.data.api_url + "api/FeijiuApp/GetCProvinceAndCity?strRSA=" + app.data.strRSA,
      //   success: function (res) {
      //     if (res.statusCode == 200) {
      //       var addr1 = res.data.data
      //       var addr2 = [
      //         {
      //         pcid: "0",
      //         code: "110000",
      //         name: "城市不限"
      //       }
      //     ]
      //       for (var i = 0; i < addr1.length; i++) {
      //         addr1[i].list.unshift(addr2[0])
      //       }
      //       var addr3 = that.data.ProvinceAndCity.concat(addr1);
      //       that.setData({
      //         ProvinceAndCity: addr3
      //       })
      //       wx.setStorageSync('ProvinceAndCity', addr3)
      //     }
      //   }
      // })

    }
  },
  // queryAddress(e) {
  //   let that = this
  //   app.getDaoPost('api/FeijiuApp/Feijiu_Get_ProvinceAndCity', e, r => {
  //     console.log(r, '地区')
  //     if (r.code == 200) {
  //       that.setData({
  //         province: r.data,
  //       })
  //     }
  //   })
  // },
  // 发布报价
  submitbaojiafabu(e) {
    let that =this
    if (this.data.classid == '') {
      wx.showToast({
        title: '请选择品类',
        icon: 'none'
      })
      return
    } else if (this.data.bjlist.length == 0) {
      wx.showToast({
        title: '请选择报价',
        icon: 'none'
      })
      return
    }else if(this.data.provinceid == 0){
      wx.showToast({
        title: '请选择地区',
        icon: 'none'
      })
      return
    }
    wx.showModal({
      title: '提示',
      content: '确定发布吗',
      success (res) {
        if (res.confirm) {
          console.log('用户点击确定')
          let input = {
            LoginUID: wx.getStorageSync('FjLoginLog').UID,
            classid: that.data.classid,
            classname: that.data.classname,
            provid: that.data.provinceid,
            cityid: that.data.cityid,
            provname: that.data.province,
            cityname: that.data.city,
            bjlist: JSON.stringify(that.data.bjlist).toString(),
            cid: that.data.cid,
      
          }
          app.getDaoPost('api/FeijiuApp/Feijiu_BJ_Edit_QuotesNew', input, r => {
            if (Array.isArray(r.data)) {
      
            } else {
              wx.showToast({
                title: r.data,
                icon: 'none'
              })
              setTimeout(()=>{
                that.setData({
                  classname: '请选择报价品类', //品类
                  classid: '',
                  bjlist: [],
                  city: '',
                  cityid: 0,
                  provinceid: 0,
                  province: '请选择地区',
                  cid: '',
                  isupdate: true
                })
              },1000)
            }
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  // 修改最高报价
  productnameInput(e) {
    let index2 = e.currentTarget.dataset.index2,
      index = e.currentTarget.dataset.index,
      list = this.data.dataList
    list[index].data[index2].maxprice = this.paseInt(e.detail.value)
    this.setData({
      dataList: list
    })
  },
  // 修改最低报价
  minpriceInput(e) {
    let index2 = e.currentTarget.dataset.index2,
      index = e.currentTarget.dataset.index,
      list = this.data.dataList
    list[index].data[index2].minprice = this.paseInt(e.detail.value)
    this.setData({
      dataList: list
    })
  },
  // 更新报价
  upPrice(e) {
    let index = e.currentTarget.dataset.index,
      list = this.data.dataList
    if (list[index].isshowupbtn != 0) {
      list[index].isshowsavebtn = true
      this.setData({
        dataList: list
      })
    }
  },
  //保存报价  Feijiu_BJ_Up_Price
  saveUpPrice(e) {
    let index = e.currentTarget.dataset.index,
      list = this.data.dataList,
      that = this
    let a = list[index].data.map((item) => {
      if (parseFloat(item.minprice) > parseFloat(item.maxprice)) {
        wx.showToast({
          title: '最低价不能高于最高价',
          icon: 'none'
        })
        return false
      } else {
        return {
          id: item.id,
          minprice: item.minprice,
          maxprice: item.maxprice
        }
      }
    })
    console.log(a)
    if (a[0] != false) {

      let input = {
        LoginUID: wx.getStorageSync('FjLoginLog').UID,
        cid: list[index].id,
        bjlist: JSON.stringify(a).toString(),
      }
      app.getDaoPost('api/FeijiuApp/Feijiu_BJ_Up_Price', input, r => {
        console.log(r, '保存报价')
        if (r.code == 500) {
          wx.showToast({
            title: r.message,
            icon: 'none'
          })
        } else {
          list[index].isshowsavebtn = false
          that.setData({
            dataList: list
          })
          // this.getDataList()
          wx.showToast({
            title: r.message,
            icon: 'none'
          })
        }
      })
    }
  },
  // 修改报价按钮
  updateBaojia(e) {
    let index = e.currentTarget.dataset.index,
      list = this.data.dataList
    this.setData({
      isupdate: false,
      tapIndex: 1,
      classname: list[index].classname, //品类
      classid: list[index].classid,
      bjlist: list[index].data,
      province: list[index].provname,
      provinceid: list[index].provinceid,
      city: list[index].cityname,
      cityid: list[index].cityid,
      cid: list[index].id,
      unit: list[index].data[0].unit,
    })

  },
  // 批量更新报价按钮
  updateBatchBaojia() {
    if (this.data.CheckedAllArr.length == 0) {
      wx.showToast({
        title: '请先选择需批量改价的报价品类',
        icon: 'none'
      })
    } else {
      this.setData({
        batchUpdateShow: true
      });
    }
  },
  onCloseBatchUpdate() { //批量更新弹窗
    this.setData({
      batchUpdateShow: false
    });
  },
  onChangeradio(event) { //单选调价
    this.setData({
      radio: event.detail,
    });
  },
  batchPriceInput(e) { //批量调整价格输入
    this.setData({
      batchPrice: e.detail.value
    })
  },
  //批量更新报价接口
  batchUpdata(e) {
    let input = {
      LoginUID: this.data.LoginUID,
      isupdown: this.data.radio,
      price: this.data.batchPrice,
      cidlist: this.data.CheckedAllArr.join(","),
    }
    if (this.data.batchPrice == '') {
      wx.showToast({
        title: '请填写调价幅度',
        icon: 'none'
      })
    } else {
      app.getDaoPost('api/FeijiuApp/Feijiu_BJ_Up_PriceList', input, r => {
        console.log(r, '调整价格')
        if (r.code == 500) {
          wx.showToast({
            title: r.message,
            icon: 'none'
          })
        } else {
          wx.showToast({
            title: r.message,
            icon: 'none'
          })
          setTimeout(() => {
            this.setData({
              batchUpdateShow: false,
              checkAllFlag: false,
              CheckedAllArr: []
            })
            this.getDataList()
          }, 1200)
        }
      })
    }
  },
  //限制两位小数
  paseInt(val) {
    let price = val
    price = price.replace(/[^\d.]/g, ""); //清除“数字”和“.”以外的字符
    price = price.replace(/\.{2}/g, ".")
    price = price.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".")
    price = price.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
    if (price.indexOf(".") < 0 && price != "") {
      price = parseFloat(price)
    }
    return price
  },
  //查看是否采集单位
  async queryisCJ() {
    let that = this
    if (app.checkFjLogin()) {
      var FjLoginLog = wx.getStorageSync('FjLoginLog');
      var api_input = {
        uid: FjLoginLog.UID,
        upwd: FjLoginLog.UPwd
      }
      //采集单位
      await app.getDaoPost('api/FeijiuApp/Post_FJ_UserInfoByUID', api_input, function (r) {
        var udata = JSON.parse(app.aesDec(r.data));
        if (udata.isCaiJiUser == 0) { //1 是 0不是没有提交申请 2不是提交过
          that.setData({
            // CJshow: true,
          })
        } else if (udata.isCaiJiUser == 2) { //
          wx.showToast({
            title: udata.CaiJiUserTips,
            icon: 'none'
          })

        }
        that.setData({
          ComName: udata.Uinfo[0].ComName,
          Linkman: udata.Uinfo[0].Linkman,
          Mobile: udata.Uinfo[0].Mobile,

        })
      })
    } else {
      wx.navigateTo({
        url: '/pages/login/index'
      });
    }
  },
  // 上传图片事件
  handlyUpLoadImg() {
    this.UpLoadImgVideo('image', 20)
  },
  //  上传附件事件
  handlyUpLoadFile() {
    this.UpLoadFileS('file', 20)
  },
  // 上传图片 mediaType：['image','video']
  UpLoadImgVideo(mediaType, count) {
    let that = this
    wx.chooseMedia({
      count: 1,
      mediaType: mediaType,
      sourceType: ['album', 'camera'],
      maxDuration: 30,
      camera: 'back',
      success(res) {
        console.log(res)
        let tempFiles = res.tempFiles
        tempFiles.forEach(item => {
          if (res.type == 'image') {
            if (tempFiles.length + that.data.upLoadImg.length + that.data.upLoadFile.length > count) {
              wx.showToast({
                title: `最多可上传${count}个文件或图片`,
                icon: 'none'
              })
              return;
            }else {
              that.upLoadImgApi(item,'images')
            }
          }else{
            wx.showToast({
              title: '请上传图片',
              icon: 'none'
            })
          }
        })
      }
    })
  },
  delUpLoadImg(e) {
    var that = this;
    let index = e.currentTarget.dataset.index,
      tempImg = that.data.upLoadImg
    let url = e.currentTarget.dataset.url;
    var strInfoJson = {fileurl:url}
    wx.showLoading({
      title: '正在删除图片...',
      mask:true
    })
    app.getDaoPost('api/FeijiuApp/Feijiu_BJ_Del_Enclosure', strInfoJson, function (r) {
      if (r.code == 200) {
        wx.hideLoading();
        app.tishi(r.message);
        tempImg.splice(index, 1);
        that.setData({
          upLoadImg: tempImg,
          uploadCount: that.data.upLoadImg.length+that.data.upLoadFile.length
        })
      } else {
        wx.hideLoading();
        app.tishi(r.message);
      }
    })
  },
  // 上传附件
  UpLoadFileS(mediaType, count) {
    let that = this
    wx.chooseMessageFile({
      count: 1,
      type: 'file',
      success (res) {
        // tempFilePath可以作为img标签的src属性显示图片
        let tempFiles = res.tempFiles
        tempFiles.forEach(item => {
            if (tempFiles.length + that.data.upLoadImg.length + that.data.upLoadFile.length > count) {
              wx.showToast({
                title: `最多可上传${count}个文件或图片`,
                icon: 'none'
              })
              return;
            }else {
              that.upLoadImgApi(item,'file')
            }
        })
      }
    })
  },
  delUpLoadFile(e) {
    var that = this;
    let index = e.currentTarget.dataset.index,
      tempImg = that.data.upLoadFile
    let url = e.currentTarget.dataset.url;
    var strInfoJson = {fileurl:url}
    wx.showLoading({
      title: '正在删除图片...',
      mask:true
    })
    app.getDaoPost('api/FeijiuApp/Feijiu_BJ_Del_Enclosure', strInfoJson, function (r) {
      if (r.code == 200) {
        wx.hideLoading();
        app.tishi(r.message);
        tempImg.splice(index, 1);
        that.setData({
          upLoadFile: tempImg,
          uploadCount: that.data.upLoadImg.length+that.data.upLoadFile.length
        })
      } else {
        wx.hideLoading();
        app.tishi(r.message);
      }
    })
   
  },
  // 上传图片接口
  upLoadImgApi(item,type) {
    console.log(item)
    let that = this;
    if(type == 'images'){
      wx.showLoading({
        title: '上传图片中',
      })
      var api_input = {}
      var arr = app.creatSecretStr('Feijiu_BJ_Upload_Enclosure',JSON.stringify(api_input));
      wx.uploadFile({
        url: app.data.api_url+'api/FeijiuApp/Feijiu_BJ_Upload_Enclosure',
        filePath: item.tempFilePath,
        name: 'file',
        formData: arr,
        success (res){
          var data = JSON.parse(res.data);
          if (data.code == 200) {
            let upLoadImg = that.data.upLoadImg
            let upLoadFile = that.data.upLoadFile
            upLoadImg.push(data.data)
            that.setData({
              upLoadImg:upLoadImg,
              uploadCount: upLoadImg.length+upLoadFile.length
            })
          }
        },
        complete(res){
          wx.hideLoading({
            complete: (hide) => {
              var data = JSON.parse(res.data);
              if (data.code != 200) {
                wx.showToast({
                  title: data.message,
                  icon: 'none'
                })
              }
            },
          })
        }
      })
    }else{
      const fileSize = item.size
      const maxSize = 1024*1024*5
      if(fileSize > maxSize) {
          wx.showToast({
            title: '文件过大，不能超过5MB',
            icon: 'none'
          })
      } else {
          wx.showLoading({
            title: '上传附件中',
          })
          var api_input = {name:item.name}
          var arr = app.creatSecretStr('Feijiu_BJ_Upload_Enclosure',JSON.stringify(api_input));
          wx.uploadFile({
            url: app.data.api_url+'api/FeijiuApp/Feijiu_BJ_Upload_Enclosure',
            filePath: item.path,
            name: 'file',
            formData: arr,
            success (res){
              var data = JSON.parse(res.data);
              if (data.code == 200) {
                let upLoadFile = that.data.upLoadFile
                let upLoadImg = that.data.upLoadImg
                let ponit = data.data.lastIndexOf(".");
                let typeFile = data.data.substr(ponit);
                if(typeFile != '.doc' && typeFile != '.docx' && typeFile != '.jpeg' && typeFile != '.jpg' && typeFile != '.pdf' && typeFile != '.png' && typeFile != '.ppt' && typeFile != '.pptx' && typeFile != '.xls' && typeFile != '.xlsx' && typeFile != '.zip'){
                  upLoadFile.push({
                    path:data.data,
                    typeFile:'other',
                    name:item.name,
                    size:that.sizeTostr(item.size)
                  });
                }else{
                  upLoadFile.push({
                    path:data.data,
                    typeFile:typeFile.replace('.',''),
                    name:item.name,
                    size:that.sizeTostr(item.size)
                  });
                }
                that.setData({
                  upLoadFile:upLoadFile,
                  uploadCount: upLoadImg.length+upLoadFile.length
                })
              }
            },
            complete(res){
              wx.hideLoading({
                complete: (hide) => {
                  var data = JSON.parse(res.data);
                  if (data.code != 200) {
                    wx.showToast({
                      title: data.message,
                      icon: 'none'
                    })
                  }
                },
              })
            }
          })
      }
    }
  },
  // 字节转换
  sizeTostr(size) {
    var data = "";
    if (size < 0.1 * 1024) { //如果小于0.1KB转化成B  
        data = size.toFixed(2) + "B";
    } else if (size < 0.1 * 1024 * 1024) {//如果小于0.1MB转化成KB  
        data = (size / 1024).toFixed(2) + "KB";
    } else if (size < 0.1 * 1024 * 1024 * 1024) { //如果小于0.1GB转化成MB  
        data = (size / (1024 * 1024)).toFixed(2) + "MB";
    } else { //其他转化成GB  
        data = (size / (1024 * 1024 * 1024)).toFixed(2) + "GB";
    }
    var sizestr = data + "";
    var len = sizestr.indexOf("\.");
    var dec = sizestr.substr(len + 1, 2);
    if (dec == "00") {
        return sizestr.substring(0, len) + sizestr.substr(len + 3, 2);
    }
    return sizestr;
  },
  //快速发布
  submitquickrelease(){
    let that = this;
    let upLoadFile = that.data.upLoadFile;
    let upLoadImg = that.data.upLoadImg;
    let upLoadImgFile = [];
    if ((upLoadFile.length + upLoadImg.length) <= 0) {
      wx.showToast({
        title: '请上传图片或文件',
        icon: 'none'
      })
      return
    } 
    if(upLoadFile.length > 0){
      upLoadFile.forEach(item => {
        upLoadImgFile.push({
          url:item.path,
          name:item.name
        })
      })
    }
    if(upLoadImg.length > 0){
      upLoadImg.forEach(item => {
        upLoadImgFile.push({
          url:item,
          name:""
        })
      })
    }
    wx.showModal({
      title: '提示',
      content: '确定发布吗',
      success (res) {
        if (res.confirm) {
          let input = {
            Ly:1,
            LoginUID: wx.getStorageSync('FjLoginLog').UID,
            enclosurelist: JSON.stringify(upLoadImgFile).toString(),
          }
          app.getDaoPost('api/FeijiuApp/Feijiu_BJ_ADD_QuotesFast', input, r => {
            if (Array.isArray(r.data)) {
            } else {
              wx.showToast({
                title: r.data,
                icon: 'none'
              })
              setTimeout(()=>{
                that.setData({
                  upLoadImg:[],//上传图片
                  upLoadFile:[],//上传附件
                  uploadCount:0
                })
              },1000)
            }
          })
        } else if (res.cancel) {
        }
      }
    })
  } 
})